package cn.itcast.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		//通知tomcat，以指定编码，处理请求中的数据
		request.setCharacterEncoding("UTF-8");
		//通知tomcat，以指定编码，处理响应中的数据。通知浏览器
		response.setContentType("text/html;charset=UTF-8"); // --> http响应头
		//response.setCharacterEncoding("GBK"); //可以修改charset=UTF-8信息
		
		//接受user参数
		String user = request.getParameter("user");
		System.out.println("loging user -->" + user);
		
		//向浏览器输出内容
		PrintWriter out = response.getWriter();
		out.print("loging user -->" + user);

	}

}
